﻿using AiShow.BLL;
using AiShow.IBLL;
using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiShow.WebSite
{
    /// <summary>
    /// 聊天集线器
    /// </summary>
    public class ChatHub : Hub
    {
        /// <summary>
        /// （服务端）发送消息
        /// </summary>
        /// <param name="selfId">发送的用户Id</param>
        /// <param name="otherId">要接收的用户Id</param>
        /// <param name="content">消息内容</param>
        /// <param name="timestamp">时间戳</param>
        public void SendMessage(int selfId, int otherId, string content, long timestamp)
        {
            // （客户端）消费消息
            Clients.User(otherId.ToString()).consumerMessage(selfId, content, timestamp);
            // 存储消息
            IFriendManager friendManager = new FriendManager();
            friendManager.SendMessage(selfId, otherId, content);
        }
    }
}